package day07;
/*
* @Author :lcy
* @Description :
* @Date 2021/11/30 22:22
*/

import day06.Student;

import java.util.ArrayList;

public class Test02_ArrayList {
    public static void main(String[] args) {
        //创建集合对象
        ArrayList<Student> list = new ArrayList<Student>();

        //创建学生对象
         Student s1 = new Student("赵丽颖",18);
         Student s2 = new Student("唐嫣",20);
         Student s3 = new Student("景甜",25);
         Student s4 = new Student("柳岩",19);

        //把学生对象作为元素添加到集合中
         list.add(s1);
         list.add(s2);
         list.add(s3);
         list.add(s4);

        for (int i = 0; i <list.size() ; i++) {
            Student s=list.get(i);
            System.out.println(s.getName()+"---"+s.getAge());
        }
        System.out.println(list);
    }
}
